package com.example.demo.domain.exam;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.annotation.Display;
import com.example.demo.dto.ObjectiveQuestionDTO;
import com.example.demo.dto.ProgrammingQuestionDTO;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.sql.Timestamp;
import java.util.List;

/**
 * 试卷信息
 * version 1.0.0
 */

@Data
@RequiredArgsConstructor
@TableName(value = "exam_paper")
public class ExamPaper {

    @Display("试卷标识")
    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    @Display("标题")
    @TableField(value = "title")
    private String title;

    @Display("试卷类型")
    @TableField(value = "paper_type")
    private String paperType;

    @Display("语言类型")
    @TableField(value = "language_type")
    private String languageType;

    @Display("创建人表示")
    @TableField(value = "creator_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long creatorId;

    @Display("试卷所属班级标识")
    @TableField(value = "class_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long classId;

    @Display("公司所属标识")
    @TableField(value = "company_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long companyId;

    @Display("试卷创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "create_time")
    private Timestamp createTime;

    @Display("试卷题目总量")
    @TableField(value = "num")
    private Integer num;

    @Display("是否禁用")
    @TableField(value = "disabled")
    private Boolean disabled;

    @Display("客观题")
    @TableField(exist = false)
    private List<ObjectiveQuestionDTO> objectiveQuestions;

    @Display("编程题")
    @TableField(exist = false)
    private List<ProgrammingQuestionDTO> programmingQuestions;

    @Display("考试总分")
    @TableField(value = "total_score")
    private Integer totalScore;

    @Display("延时时间（分）")
    @TableField(exist = false)
    private Integer delayTime;

    @Display("当前用户考试第一次进入时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(exist = false)
    private Timestamp firstEnterTime;

    @Display("当前考试开始时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(exist = false)
    private Timestamp startTime;

    @Display("当前结束开始时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(exist = false)
    private Timestamp endTime;

    @Display("考试时长")
    @TableField(exist = false)
    private Long durationTime;

}
